/*
** image.c for RayTracer in /home/jeanma_d//Damien/Igraph/RayTracer/image.c
**
** Made by damien jeanmaire
** Login   <jeanma_d@epitech.net>
**
** Started on  Thu Dec  8 16:41:22 2011 damien jeanmaire
** Last update Thu Apr 26 17:07:16 2012 damien jeanmaire
*/

#include	"rt.h"

void		my_pixel_put_to_image(t_img *img, int x, int y,
				      unsigned long color)
{
  int		i;
  unsigned long	mask;
  unsigned char	tmp_clr;
  int		offset;

  i = 0;
  if (x >= 0 && x < img->size.x && y >= 0 && y < img->size.y)
    while (i < (img->bpp / 8))
      {
	if (img->endi == 1)
	  offset = img->bpp - 8 * (i + 1);
	else
	  offset = 8 * i;
	mask = 0xFF << offset;
	tmp_clr = (color & mask) >> offset;
	img->data[y * (img->szl) + x * (img->bpp / 8) + i] = tmp_clr;
	i++;
      }
}
